$(function(){

	var wsUrl = "ws://103.21.142.12:50271";
	var websocket = new WebSocket(wsUrl);

	websocket.onopen = function(){
	}

	websocket.onmessage = function(event){
		push(event.data);
	}

	websocket.onclose = function(event){
		console.log("close");
	}

	websocket.onerror = function(event,error){
		console.log('error');
	}


	function push(data){
		var jsonData = JSON.parse(data);

		html = '';
		html += '<div class="frame">';
		html +=	'<h3 class="frame-header">';
		html +=	'<i class="icon iconfont icon-shijian"></i>'+jsonData.type+'01：30';
		html +=	'</h3>';
		html +=	'<div class="frame-item">'
		html +=	'<span class="frame-dot"></span>';
		html +=	'<div class="frame-item-author">';
		if(jsonData.logo){
			html +=	'<img src="'+jsonData.logo+'" width="20px" height="20px" />';
		}
		html +=	jsonData.title+'</div>';
		html +=	'<p>'+jsonData.content+'</p>';
		html +=	'<p><img src="'+jsonData.image+'" width="40%" /></p>';
		html += '</div>';
		$("#match-result").prepend(html);
	}
});